package com.av.android;

import java.util.List;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

/**
 * @author mwho
 * 
 */
public class SearchActivity2 extends TabActivity {

	private TabHost mTabHost;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_member);
		mTabHost = getTabHost();
		TabSpec firstTabSpec = mTabHost.newTabSpec("tid1");
		TabSpec secondTabSpec = mTabHost.newTabSpec("tid2");
		TabSpec thirdTabSpec = mTabHost.newTabSpec("tid3");

		firstTabSpec.setIndicator("Search Violation").setContent(
				new Intent(this, SerachOptionsActivity.class));
		secondTabSpec.setIndicator("Results").setContent(
				new Intent(this, ResultsActivity.class));
		thirdTabSpec.setIndicator("View Map").setContent(
				new Intent(this, MapsActivity.class).putExtra("search", true));

		mTabHost.addTab(firstTabSpec);
		mTabHost.addTab(secondTabSpec);
		mTabHost.addTab(thirdTabSpec);
		
	}

	public void refreshResults(List<Report> reports) {
		
		getTabHost().setCurrentTab(2);
		MapsActivity mapsActivity = (MapsActivity)this.getCurrentActivity();
		mapsActivity.showReportsInMap(reports);
		getTabHost().setCurrentTab(1);
		ResultsActivity activity = (ResultsActivity)this.getCurrentActivity();
		activity.refresh(reports);
//		ResultsActivity childAct = (ResultsActivity) getLocalActivityManager().getActivity("tid2");
//		childAct.refresh(reports);
//		MapsActivity maps = (MapsActivity)getLocalActivityManager().getActivity("tid3");
//		maps.showReportsInMap(reports);
//		
	}
}
